package com.example.accessingdatajpa.controller;

import com.example.accessingdatajpa.pojo.FirstPage;
import com.example.accessingdatajpa.response.RestResponse;
import com.example.accessingdatajpa.service.IFirstPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app")
public class FirstPageController {
    @Autowired
    final private IFirstPageService firstPageService;

    public FirstPageController(IFirstPageService firstPageService) {
        this.firstPageService = firstPageService;
    }

    //得到全部图片地址url
    @GetMapping(path = "/first-page-all")
    public @ResponseBody RestResponse<List<FirstPage>> findAllFirstPicUrl(){
        return firstPageService.queryAllFirstPicUrl();
    }

    //添加url
    @PostMapping(path = "/first-page-add")
    public @ResponseBody RestResponse<String> addNewFruit (@RequestBody FirstPage firstPage){
        return firstPageService.addOnePicUrl(firstPage);
    }
}
